#include <bits/stdc++.h>
using namespace std;
int a[100010], b[100010];
int main(){
    freopen("arena.in", "r", stdin);
    freopen("arena.out", "w", stdout);
    int n, m, t;
    cin >> n;
    cin >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    cin >> t;
    int x_0[260], x_1[260], x_2[260], x_3[260];
    for(int i = 0; i < t; i++){
        cin >> x_0[i] >> x_1[i] >> x_2[i] >> x_3[i];
    }
    for(int i = 0; i < t; i++){
        cout << 1 << endl;
    }
    return 0;
}
